package com.zyf.project.capchain.config;

import com.zyf.project.capchain.interceptor.JwtInterceptor;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Zhou Yifan
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public JwtInterceptor getJwtInterceptor() {
        return new JwtInterceptor();
    }

    @Override
    public void addInterceptors(@NotNull InterceptorRegistry registry) {
        registry.addInterceptor(getJwtInterceptor())
                .addPathPatterns("/user/api/**")
                .excludePathPatterns("/user/api/wxlogin")
                .excludePathPatterns("/scan")
                .excludePathPatterns("/data")
                .excludePathPatterns("/create")
                .excludePathPatterns("/mine");
    }

}
